<?php


/**
 * Greendizer invoice view
 *
 * @author      Youssef El Bied <youssef@greendizer.com>
 */
class Greendizer_Module_Block_View extends Mage_Adminhtml_Block_Sales_Order_Invoice_View
{
    public function __construct()
    {
        parent::__construct();

        if ($this->getInvoice()->isSentToGreendizer())
        {
            $params = array('id' => $this->getInvoice()->getId());
            if ($secretKey = $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME))
            {
                $params[Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME] = $secretKey;
            }
            $this->_addButton('view_in_greendizer', array(
                'label'     => Mage::helper('sales')->__('View in Greendizer'),
                'style'		=> 'background: #070 url(http://www.greendizer.com/static/icons/gd16bw.png) no-repeat 3px 0; padding-left: 20px; border-color: #070;',
                'onclick'   => 'window.open(\''.Mage::getUrl('greendizer/invoice/index', $params).'\')'
                )
            );
        }
    }
}
